// This is to prevent duplicate symbols when used with C++ interface
#define PURG_C_INTERFACE_COMPILE
#include <purg.h>

extern "C"
{

  int *purg_init_rng ( size_t seed1 , size_t seed2 , size_t stream_id )
  {
    parallel_gen  *generator = new parallel_gen ( seed1 , seed2 , stream_id );
    return reinterpret_cast<int *> ( generator );
  }
  
  void  purg_destroy_rng ( int *gen )
  {
    parallel_gen  *generator = reinterpret_cast<parallel_gen *> ( gen );
    delete generator;
  }

  double  purg_double ( int *gen , double min , double max )
  {
    parallel_gen  *generator = reinterpret_cast<parallel_gen *> ( gen );
    double ret_val;
    generator->get ( ret_val , min , max );
    return ret_val;
  }

  float  purg_float ( int *gen , float min , float max )
  {
    parallel_gen  *generator = reinterpret_cast<parallel_gen *> ( gen );
    float ret_val;
    generator->get ( ret_val , min , max );
    return ret_val;
  }

  int   purg_int_bounded ( int *gen , int min , int max )
  {
    parallel_gen  *generator = reinterpret_cast<parallel_gen *> ( gen );
    int ret_val;
    generator->get ( ret_val , min , max );
    return ret_val;
  }

  int   purg_int ( int *gen )
  {
    parallel_gen  *generator = reinterpret_cast<parallel_gen *> ( gen );
    int ret_val;
    generator->get ( ret_val );
    return ret_val;
  }

  long   purg_long_bounded ( int *gen , long min , long max )
  {
    parallel_gen  *generator = reinterpret_cast<parallel_gen *> ( gen );
    long ret_val;
    generator->get ( ret_val , min , max );
    return ret_val;
  }

  long   purg_long ( int *gen )
  {
    parallel_gen  *generator = reinterpret_cast<parallel_gen *> ( gen );
    long ret_val;
    generator->get ( ret_val );
    return ret_val;
  }

  size_t   purg_size_t_bounded ( int *gen , size_t min , size_t max )
  {
    parallel_gen  *generator = reinterpret_cast<parallel_gen *> ( gen );
    size_t ret_val;
    generator->get ( ret_val , min , max );
    return ret_val;
  }

  size_t   purg_size_t ( int *gen )
  {
    parallel_gen  *generator = reinterpret_cast<parallel_gen *> ( gen );
    size_t ret_val;
    generator->get ( ret_val );
    return ret_val;
  }

  unsigned int   purg_uint_bounded ( int *gen , unsigned int min , unsigned int max )
  {
    parallel_gen  *generator = reinterpret_cast<parallel_gen *> ( gen );
    unsigned int ret_val;
    generator->get ( ret_val , min , max );
    return ret_val;
  }

  unsigned int   purg_uint ( int *gen )
  {
    parallel_gen  *generator = reinterpret_cast<parallel_gen *> ( gen );
    unsigned int ret_val;
    generator->get ( ret_val );
    return ret_val;
  }

  unsigned long   purg_ulong_bounded ( int *gen , unsigned long min , unsigned long max )
  {
    parallel_gen  *generator = reinterpret_cast<parallel_gen *> ( gen );
    unsigned long ret_val;
    generator->get ( ret_val , min , max );
    return ret_val;
  }

  unsigned long   purg_ulong ( int *gen )
  {
    parallel_gen  *generator = reinterpret_cast<parallel_gen *> ( gen );
    unsigned long ret_val;
    generator->get ( ret_val );
    return ret_val;
  }

  void  purg_fill_buffer ( int *gen , void *buf , size_t length )
  {
    parallel_gen  *generator = reinterpret_cast<parallel_gen *> ( gen );
    generator->get_raw_buffer ( length , buf );
  }
}
